home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5105 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news.lpr.carel.fi!usenet
  2. From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How to tell if a file exists in C
  5. Date: Thu, 08 Feb 1996 16:31:43 +0200
  6. Organization: Carelcomp Forest
  7. Message-ID: <311A094F.6F12@cmt.lpr.mail.carel.fi>
  8. References: <823685019.AA00170@escan.demon.co.uk>
  9. NNTP-Posting-Host: renoir.cclahti.carel.fi
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b6a (WinNT; I)
  14.  
  15. Bill Birrell wrote:
  16. >  > Hi, how do I find out if a file already exists
  17. >  > in UNIX C? On PCs I would do a findfirst/findnext,
  18. >  > is there an equivalent on Unix?
  19. >     Check up on access() and stat(). There cannot be an exact equivalent to
  20. > Digital Research's findfirst and findnext functions in unix, because unix has
  21. > a completely different file structure from CP/M or PC-Dos (later MsDos), and
  22. > therefore has no idea what FCBs are. Files, directories and devices are all
  23. > accessed the same way, and when you become used to it, it is a *much* simpler
  24. > and more logical approach. Take a look at K&R Chapter 8 [Either edition - it's
  25. > in both].
  26.  
  27. If you know the name of the file the existance of which you want to check, try
  28.  
  29.     remove(filename);
  30.  
  31. If it succeeded, the file did exist. :)
  32.  
  33. Later,
  34.  AriL
  35. -- 
  36. All my opinions are mine and mine alone.
  37.